{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import pickle\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "from tqdm import tqdm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataset = \"beauty\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = {}\n",
    "\n",
    "with open(f\"./{dataset}/handled/inter_seq.txt\", 'r') as f:\n",
    "    for line in tqdm(f):\n",
    "        line_data = line.rstrip().split(' ')\n",
    "        user_id = line_data[0]\n",
    "        line_data.pop(0)    # delete user_id\n",
    "        data[user_id] = line_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(f\"./{dataset}/handled/inter.txt\", 'w') as f:\n",
    "    for user, item_list in tqdm(data.items()):\n",
    "        for item in item_list:\n",
    "            u = int(user)\n",
    "            i = int(item)\n",
    "            f.write('%s %s\\n' % (u, i))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "llm",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.5"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
